package org.finesys.samples.file.bio;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class BioClient {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("localhost", 8080);
            //接收来自服务端的消息
            InputStream inputStream = socket.getInputStream();
            BufferedReader bufferedInputStream = new BufferedReader(new InputStreamReader(inputStream));
            while (true) {
                String message = bufferedInputStream.readLine();
                if (message == null) {
                    break;
                }
                System.out.println("接收到数据：" + message);
                //给服务端发送消息
                PrintWriter printWriter = new PrintWriter(socket.getOutputStream(), true);
                printWriter.println("客户端接收数据并响应");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
        }


    }
}
